/* util. GEN K+V */
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "kv_pair.h"

void generate(int id, KV* cur_kv);
int main()
{
	int fd, i;
	KV cur_kv;
	fd=open("/tmp/kv_pair", O_RDWR | O_CREAT , S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);

	
	for (i=0; i<KV_MAX_CNT; i++)
	{
		generate(i, &cur_kv);
		write(fd, &cur_kv, sizeof(KV));
		//printf ("%s\n", cur_kv.key);
	}

	printf ("\n");
	close(fd);

	return 0;
}


void generate(int id, KV* cur_kv)
{
	int pos;
	memset(cur_kv->key, 0, 64);
	memset(cur_kv->value, 0, 64);
		
	for (pos=0; pos<60; pos++)
	{
		cur_kv->key[pos]='a'+id%26;
		id/=26;
	}
	strcpy(cur_kv->value, cur_kv->key);
}
				

